package com.xbkj.pgrp.server.model.app;

import lombok.Getter;
import lombok.Setter;
import xyz.erupt.annotation.Erupt;
import xyz.erupt.annotation.EruptField;
import xyz.erupt.annotation.sub_erupt.Tab;
import xyz.erupt.annotation.sub_field.Edit;
import xyz.erupt.annotation.sub_field.EditType;
import xyz.erupt.annotation.sub_field.View;
import xyz.erupt.annotation.sub_field.sub_edit.ReferenceTableType;
import xyz.erupt.upms.model.base.HyperModel;

import javax.annotation.Resource;
import javax.persistence.*;

@Erupt(
        name = "项目资源信息"
)
@Entity
@Table(name = "pgrp_project_resource", uniqueConstraints = @UniqueConstraint(columnNames = {"project_id", "role_id", "employee_id"}))
@Setter
@Getter
public class ProjectResource extends HyperModel {
    @ManyToOne
    @JoinColumn(name = "project_id")
    @EruptField(
//            views = {
//                    @View(title = "项目编号", column = "id"),
//                    @View(title = "项目名称", column = "projectName"),
//                    @View(title = "计划开始时间", column = "originBeginDate"),
//                    @View(title = "计划结束时间", column = "originEndDate")
//            }
//            edit = @Edit(title = "项目信息",  type = EditType.REFERENCE_TABLE,
//            referenceTableType = @ReferenceTableType(id = "id", label = "projectName"))
    )
    private Project project;

    @OneToOne
    @JoinColumn(name = "role_id")
    @EruptField(
            views = {
                    @View(title = "角色名称", column = "roleName")
            },
            edit = @Edit(title = "角色信息",  type = EditType.REFERENCE_TABLE,
            referenceTableType = @ReferenceTableType(id = "id", label = "roleName"))
    )
    private Role role;

    @OneToOne
    @JoinColumn(name = "employee_id")
    @EruptField(
            views = {
                    @View(title = "员工工号", column = "no"),
                    @View(title = "员工姓名", column = "name")

            },
            edit = @Edit(title = "员工信息",  type = EditType.REFERENCE_TABLE,
            referenceTableType = @ReferenceTableType(id = "id", label = "name"))
    )
    private Employee employee;

    @EruptField(
            views = @View(title = "总投入天数")
    )
    @Transient
    private Long totalDays = 1l;
}
